<!DOCTYPE html>


<html lang="zh-CN">


<head>
  <meta charset="utf-8" />
    
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <title>
    分享二十个mysql运维案例.md |  
  </title>
  <meta name="generator" content="hexo-theme-ayer">
  
  <link rel="shortcut icon" href="/favicon.ico" />
  
  
<link rel="stylesheet" href="/dist/main.css">

  
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Shen-Yu/cdn/css/remixicon.min.css">

  
<link rel="stylesheet" href="/css/custom.css">

  
  
<script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>

  
  

  

</head>

</html>

<body>
  <div id="app">
    
      
    <main class="content on">
      <section class="outer">
  <article
  id="post-mysql/分享二十个mysql运维案例"
  class="article article-type-post"
  itemscope
  itemprop="blogPost"
  data-scroll-reveal
>
  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  分享二十个mysql运维案例.md
</h1>
 

    </header>
     
    <div class="article-meta">
      <a href="/2020/11/11/mysql/%E5%88%86%E4%BA%AB%E4%BA%8C%E5%8D%81%E4%B8%AAmysql%E8%BF%90%E7%BB%B4%E6%A1%88%E4%BE%8B/" class="article-date">
  <time datetime="2020-11-10T16:00:00.000Z" itemprop="datePublished">2020-11-11</time>
</a> 
  <div class="article-category">
    <a class="article-category-link" href="/categories/mysql/">mysql</a>
  </div>
  
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> 字数统计:</span>
            <span class="post-count">3.3k</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> 阅读时长≈</span>
            <span class="post-count">15 分钟</span>
        </span>
    </span>
</div>
 
    </div>
      
    <div class="tocbot"></div>




  
    <div class="article-entry" itemprop="articleBody">
       
  <h1 id="分享二十个mysql运维案例"><a href="#分享二十个mysql运维案例" class="headerlink" title="分享二十个mysql运维案例"></a>分享二十个mysql运维案例</h1><p>日常mysql运维中，会遇到各种各样的问题，下面分享二十个mysql运维案例，附有问题的分析和解决办法，希望你遇到同样的问题的时候，可以淡定地处理。</p>
<h3 id="一-执行存储过程-函数报错账号不存在"><a href="#一-执行存储过程-函数报错账号不存在" class="headerlink" title="一.执行存储过程/函数报错账号不存在"></a>一.执行存储过程/函数报错账号不存在</h3><p>问题描述：执行存储过程报错<br><code>mysql&gt;call create_no_by_day(&#39;STUDENT&#39;,&#39;CREATE_TIME&#39;);</code><br><code>ERROR 1449 (HY000):The user specified as a definer (&#39;TEST_111&#39;@&#39;172.%.%.%&#39;) does not exist</code></p>
<p>分析：这情况是因为当时机器上这存储过程是由用户’TEST_111’@’172.%.%.%‘创建，但是存储过程导入到了新的机器后，这新机器没有这个用户而报错。<br>三种解决办法：<br>1、重建这个存储过程，把definer那段代码取消。<br>2、在新机器上建立这个用户’TEST_111’@‘172.%.%.%’。<br>3、修改定义者，替换所有存储过程是这个定义者的为新机器已有账号。</p>
<p>解决：修改定义者<br>1.查看机器不存在这个账号<br><code>select host,user from mysql.user where host=&#39;172.%.%.%&#39; and user=&#39;TEST_111&#39;;</code></p>
<p>2.替换所有存储过程是这个定义者的为新机器已有账号。<br><code>UPDATE  mysql.proc set DEFINER=&#39;TEST_222@172.%.%.%&#39; where DEFINER=&#39;TEST_111@172.%.%.%&#39;;</code></p>
<h3 id="二-遇到DDL变更的时候发生阻塞"><a href="#二-遇到DDL变更的时候发生阻塞" class="headerlink" title="二.遇到DDL变更的时候发生阻塞"></a>二.遇到DDL变更的时候发生阻塞</h3><p>问题描述：添加字段、添加索引等DDL语句时候会被阻塞，show processlist 会看到显示 Waiting for table metadata lock. 后续的对这些表的select也会被阻塞<br>分析：autocommit=0，怀疑有未提交事务，导致产生了元数据锁。<br>解决：<br>1.如果打开了performance_schema 监控，通过语句定位未提交事务：<br>SELECT<br>locked_schema,<br>locked_table,<br>locked_type,<br>waiting_processlist_id,<br>waiting_age,<br>waiting_query,<br>waiting_state,<br>blocking_processlist_id,<br>blocking_age,<br>substring_index(sql_text,“transaction_begin;” ,-1) AS blocking_query,<br>sql_kill_blocking_connection<br>FROM<br>(<br>SELECT<br>b.OWNER_THREAD_ID AS granted_thread_id,<br>a.OBJECT_SCHEMA AS locked_schema,<br>a.OBJECT_NAME AS locked_table,<br>“Metadata Lock” AS locked_type,<br>c.PROCESSLIST_ID AS waiting_processlist_id,<br>c.PROCESSLIST_TIME AS waiting_age,<br>c.PROCESSLIST_INFO AS waiting_query,<br>c.PROCESSLIST_STATE AS waiting_state,<br>d.PROCESSLIST_ID AS blocking_processlist_id,<br>d.PROCESSLIST_TIME AS blocking_age,<br>d.PROCESSLIST_INFO AS blocking_query,<br>concat(‘KILL ‘, d.PROCESSLIST_ID) AS sql_kill_blocking_connection<br>FROM<br>performance_schema.metadata_locks a<br>JOIN performance_schema.metadata_locks b ON a.OBJECT_SCHEMA = b.OBJECT_SCHEMA<br>AND a.OBJECT_NAME = b.OBJECT_NAME<br>AND a.lock_status = ‘PENDING’<br>AND b.lock_status = ‘GRANTED’<br>AND a.OWNER_THREAD_ID &lt;&gt; b.OWNER_THREAD_ID<br>AND a.lock_type = ‘EXCLUSIVE’<br>JOIN performance_schema.threads c ON a.OWNER_THREAD_ID = c.THREAD_ID<br>JOIN performance_schema.threads d ON b.OWNER_THREAD_ID = d.THREAD_ID<br>) t1,<br>(<br>SELECT<br>thread_id,<br>group_concat( CASE WHEN EVENT_NAME = ‘statement/sql/begin’ THEN “transaction_begin” ELSE sql_text END ORDER BY event_id SEPARATOR “;” ) AS sql_text<br>FROM<br>performance_schema.events_statements_history<br>GROUP BY thread_id<br>) t2<br>WHERE<br>t1.granted_thread_id = t2.thread_id</p>
<p>2.杀进程kill blocking_processlist_id</p>
<p>3.没有打开wait/lock/metadata/sql/mdl情况下，针对sleep进程执行kill<br>SELECT concat(‘kill ‘,processlist_id,’;’)<br>FROM performance_schema.events_statements_current a JOIN performance_schema.threads b USING(thread_id)<br>JOIN information_schema.processlist c ON b.processlist_id = c.id<br>WHERE a.sql_text NOT LIKE ‘%performance%’ and command=‘sleep’ order by c.time desc;</p>
<h3 id="三-批量更新数据卡住"><a href="#三-批量更新数据卡住" class="headerlink" title="三.批量更新数据卡住"></a>三.批量更新数据卡住</h3><p>问题描述：批量更新很慢，没添加索引，添加索引被阻塞<br>分析：事务不自动提交容易造成元数据锁冲突<br>解决：执行SELECT concat(‘kill ‘,processlist_id,’;’)<br>FROM performance_schema.events_statements_current a JOIN performance_schema.threads b USING(thread_id)<br>JOIN information_schema.processlist c ON b.processlist_id = c.id<br>WHERE a.sql_text NOT LIKE ‘%performance%’ and command=‘sleep’ order by c.time desc;<br>杀进程</p>
<h3 id="四-一个环境数据库占用空间满情况"><a href="#四-一个环境数据库占用空间满情况" class="headerlink" title="四.一个环境数据库占用空间满情况"></a>四.一个环境数据库占用空间满情况</h3><p>问题描述：一个环境数据库空间已满。<br>分析：数据没有定时清理，没有监控报警。一个保存实时消息的大表上百亿数据占用过大<br>问题解决：1.能登陆mysql情况下，truncate table 大表(无用数据，可清除)，回收空间<br>2.不能登陆mysql情况下，删除部分binlog日志，让mysql启动起来，再清理其他数据。</p>
<h3 id="五-数据库迁移"><a href="#五-数据库迁移" class="headerlink" title="五.数据库迁移"></a>五.数据库迁移</h3><p>问题描述：已备份了数据，想把数据库导进另一个环境，但是想换一个数据库名字，以免把另一个环境的同名数据库覆盖<br>问题解决：<br>1.导出数据<br><code># mysqldump -uroot -pxxx_001 --set-gtid-purged=OFF admin &gt; admin.sql</code></p>
<p>2． 建新库<br><code>mysql&gt;create database admin1;</code></p>
<p>3． 建立账号，授权<br><code>mysql&gt;CREATE USER admin1@&#39;%&#39; identified by &#39;Admin1_!@#&#39;;</code><br><code>mysql&gt;GRANT ALL PRIVILEGES ON  admin1.* TO admin1@&#39;%&#39;;</code><br><code>mysql&gt;flush privileges;</code></p>
<p>4． 导入数据到新库admin1<br><code># mysql -uroot -pxxx_001 admin1 &lt;admin.sql</code></p>
<p>这样，就把原库admin导出的表数据，导入了新库admin1里面。新账号admin1已授权访问新库admin1,新账号密码是Admin1_!@#</p>
<p>注： 操作2,3是sql语句，在mysql里面执行。 操作1,4是在linux命令行上操作。</p>
<h3 id="六-数据库日志出现多个断连记录"><a href="#六-数据库日志出现多个断连记录" class="headerlink" title="六.数据库日志出现多个断连记录"></a>六.数据库日志出现多个断连记录</h3><p>问题描述：数据库日志出现多个断连记录，显示为Got an error writing communication packets<br>分析：有可能是客户端异常退出了，应用重启，也有可能是网络链路异常。这种提示一般是[NOTE],属于提示信息。<br>问题解决：<br>关闭警报<br>set global log_warning=1;<br>另：若是出现Got timeout reading communication packets或者Got timeout writing communication packets，属于客户端的空连接时间过长，超过了wait_timeout和interactive_timeout的时间，可以调整wait_timeout/interactive_timeout</p>
<h3 id="七-非法断电造成mysql启动报错"><a href="#七-非法断电造成mysql启动报错" class="headerlink" title="七.非法断电造成mysql启动报错"></a>七.非法断电造成mysql启动报错</h3><p>问题描述：非法断电造成mysql数据损坏<br>分析：突然断电造成缓存数据丢失，跟已刷盘的数据不一致。需要重做从库。<br>问题解决：到主库物理备份数据，恢复到从库，恢复主从同步。<br>物理备份恢复过程：<br>主库:<br>mysqlbackup –user=root –password=xxx_001 –backup-dir=/mysql/data/backup –backup-image=./dball.mbi –with-timestamp –compress-level=9 –compress-method=zlib –skip-binlog –skip-relaylog backup-to-image #备份数据<br>scp dball.mbi <a href="mailto:&#x72;&#111;&#111;&#116;&#x40;&#x31;&#x39;&#x32;&#46;&#x31;&#x36;&#x38;&#x2e;&#x31;&#51;&#55;&#x2e;&#x31;&#x31;&#49;">&#x72;&#111;&#111;&#116;&#x40;&#x31;&#x39;&#x32;&#46;&#x31;&#x36;&#x38;&#x2e;&#x31;&#51;&#55;&#x2e;&#x31;&#x31;&#49;</a>:/mysql/data/backup/ #拷贝到目标机器backup目录</p>
<p>从库:<br>cd /mysql/data/backup/<br>chown mysql.mysql dball.mbi<br>su - mysql<br>mysql.server stop<br>cd /mysql/data/undo<br>rm -rf * #清空undo日志<br>cd /mysql/data/redo<br>rm -rf * #清空redo日志<br>cd /mysql/data/dbs<br>rm -rf * #清空数据<br>mysqlbackup –backup-image=/mysql/data/backup/dball.mbi –backup-dir=/mysql/data/backup –uncompress copy-back-and-apply-log –force #恢复数据<br>mysql.server start #启动mysql<br>mysql -uroot -p<br>reset slave all; #重置<br>change master to master_host = ‘192.168.137.110’, master_port = 3310, master_user = ‘rpl_user’, master_password = ‘rpl_001’, master_auto_position=1 ;#设置主从同步复制<br>start slave;#启动同步<br>show slave status\G;#查看同步状况</p>
<h3 id="八-非法断电造成mysql同步复制无法启动"><a href="#八-非法断电造成mysql同步复制无法启动" class="headerlink" title="八.非法断电造成mysql同步复制无法启动"></a>八.非法断电造成mysql同步复制无法启动</h3><p>问题描述：relay报错，error:look foring afer relay.000013<br>分析：relay得到的gtid比执行的gtid少，得到的部分gtid丢失。<br>show slave status\G;<br>Master_UUID: 37be0d7b-e11e-11e9-bafb-fa163e9dcbee<br>Retrieved_Gtid_Set: 37be0d7b-e11e-11e9-bafb-fa163e9dcbee:2290-2302(少)<br>Executed_Gtid_Set: 37be0d7b-e11e-11e9-bafb-fa163e9dcbee:1-2352(大),<br>5324e653-f0c2-11e9-84d0-fa163e897a41:1-363,<br>5661dce0-e11e-11e9-ab09-fa163e897a41:1-318</p>
<p>问题解决：<br>调整gtid，以relay获得的gtid为准，重做主从同步<br>reset slave all;#重置<br>reset master;#重置<br>SET @@GLOBAL.GTID_PURGED=‘37be0d7b-e11e-11e9-bafb-fa163e9dcbee:1-2302(少),5324e653-f0c2-11e9-84d0-fa163e897a41:1-363,5661dce0-e11e-11e9-ab09-fa163e897a41:1-318’;#以relay获得的gtid为准，设置GTID_PURGED<br>change master to master_host = ‘192.168.137.110’, master_port = 3310, master_user = ‘rpl_user’, master_password = ‘rpl_001’, master_auto_position=1 ;#设置主从同步复制<br>start slave; #启动同步<br>show slave status\G;#查看同步状况</p>
<h3 id="九-mysql压力测试，插入时间增大，压不上去"><a href="#九-mysql压力测试，插入时间增大，压不上去" class="headerlink" title="九.mysql压力测试，插入时间增大，压不上去"></a>九.mysql压力测试，插入时间增大，压不上去</h3><p>问题描述：压力测试，数据库插入出现延时情况。<br>分析：沟通发现，mysql是个人安装，非标准化，设置不当，例如32G的内存，innodb_buffer_pool_size只默认128M。<br>问题解决：<br>1.动态在线增大innodb_buffer_pool_size值。<br>set global innodb_buffer_pool_size=16<em>1024</em>1024*1024;</p>
<p>2.为了永久生效，在my.cnf里面设置<br>innodb_buffer_pool_size=16G<br>innodb_buffer_pool_instances = 8<br>重启mysql</p>
<h3 id="十-通过恢复文件加载空间恢复表数据"><a href="#十-通过恢复文件加载空间恢复表数据" class="headerlink" title="十.通过恢复文件加载空间恢复表数据"></a>十.通过恢复文件加载空间恢复表数据</h3><p>问题描述：出现测试环境数据库ibdata1损坏，无法启动。<br>分析：通过开发环境的mysql全量备份，恢复到测试环境。由于开发环境的admin库数据库结构跟测试环境的admin库一样，但是数据不一样，需要用原测试环境数据文件恢复原表数据。<br>问题解决：<br>1.备份数据<br>mkdir backup<br>cp dbs/admin/* backup/<br>2.开发环境mysqlbackup全量备份恢复到测试环境<br>3.卸载库admin所有表空间<br>mysql -uroot -p -e “select concat(‘alter table ‘,table_name,’ DISCARD tablespace;’) from information_schema.TABLES where table_schema=‘admin’ and table_type=‘BASE TABLE’;” &gt;admin_discard.sql<br>vi admin_discard.sql<br>删除第一行concat(‘alter table ‘,table_name,’ DISCARD tablespace;’)<br>mysql -uroot -p admin &lt;admin_discard.sql<br>4.拷贝回.ibd文件<br>cp -f backup/*.ibd dbs/admin/<br>5.加载库admin所有表空间<br>mysql -uroot -p -e “select concat(‘alter table ‘,table_name,’ IMPORT tablespace;’) from information_schema.TABLES where table_schema=‘admin’ and table_type=‘BASE TABLE’;” &gt;admin_import.sql<br>vi admin_import.sql<br>删除第一行concat(‘alter table ‘,table_name,’ IMPORT tablespace;’)<br>mysql -uroot -p admin &lt;admin_import.sql<br>6.启动mysql<br>mysql.server start</p>
<h3 id="十一-XA事务未提交，更新数据超时"><a href="#十一-XA事务未提交，更新数据超时" class="headerlink" title="十一.XA事务未提交，更新数据超时"></a>十一.XA事务未提交，更新数据超时</h3><p>问题描述：出现更新数据超时问题<br>分析：查看事务进程，发现有未提交的xa事务，thread_id为0.<br>问题解决：</p>
<p>1.先列出xa事务<br>mysql&gt; xa recover;<br>±———±————-±————-±———————————————————————————————————————————+<br>| formatID | gtrid_length | bqual_length | data |<br>±———±————-±————-±———————————————————————————————————————————+<br>| 3072 | 64 | 64 | PRBMPAPP4/c734a63e-211f-4202-8aa9-78d2/174064445 3 |<br>±———±————-±————-±———————————————————————————————————————————+<br>1 row in set (0.10 sec)<br>xa回滚的格式是xa rollback ‘left(data,gtrid_length)’,‘substr(data,gtrid_length+1,bqual_length)’,formatid;<br>2.转16制<br>mysql&gt; set session autocommit=1;<br>Query OK, 0 rows affected (0.00 sec)</p>
<p>mysql&gt; xa recover convert xid;<br>±———±————-±————-±——————————————————————————————————————————————————————————————————————————————————————-+<br>| formatID | gtrid_length | bqual_length | data |<br>±———±————-±————-±——————————————————————————————————————————————————————————————————————————————————————-+<br>| 3072 | 64 | 64 | 0x5052424D50415050342F63373334613633652D323131662D343230322D386161392D373864322F3137343036343434350000000000000000000000000000000033000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |<br>±———±————-±————-±——————————————————————————————————————————————————————————————————————————————————————-+<br>1 row in set (0.00 sec)<br>3.回滚事务<br>mysql&gt; xa rollback 0x5052424D50415050342F63373334613633652D323131662D343230322D386161392D373864322F31373430363434343500000000000000000000000000000000,0x33000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,3072;<br>Query OK, 0 rows affected (0.01 sec)</p>
<h3 id="十二-mysql升级5-7-26，更换驱动后原账号连不上"><a href="#十二-mysql升级5-7-26，更换驱动后原账号连不上" class="headerlink" title="十二.mysql升级5.7.26，更换驱动后原账号连不上"></a>十二.mysql升级5.7.26，更换驱动后原账号连不上</h3><p>问题描述：mysql从5.7.24升级到mysql5.7.26，驱动从mysql connector java更换为mariadb，业务升级前就是这个密码，运行很久，有3套mysql，有1套重启数据库还不能恢复，有2套重启数据库恢复了<br>分析：mariadb驱动对sha256_password识别不好，改用低版本mysql_native_password<br>问题解决：<br>1.查询当前密码加密方式<br>SELECT user, host, plugin FROM mysql.user;<br>mysql&gt; SELECT user, host, plugin FROM mysql.user;<br>±————–±————–±———————-+<br>| user | host | plugin |<br>±————–±————–±———————-+<br>| root | % | sha256_password |<br>| mysql.session | localhost | mysql_native_password |<br>| mysql.sys | localhost | mysql_native_password |<br>| mysql_om | % | sha256_password |<br>| rpl_user | 10.110.10.19 | sha256_password |<br>| root | 10.110.10.156 | sha256_password |<br>| xxxadmin | % | sha256_password |<br>| xxxuser | % | sha256_password |<br>| mysql | % | sha256_password |<br>±————–±————–±———————-+<br>14 rows in set (0.00 sec)<br>2.修改加密方式<br>ALTER USER ‘xxxuser’@’%’ IDENTIFIED WITH mysql_native_password BY ‘XXX_1234’;<br>flush privileges;</p>
<h3 id="十三-mysql无法启动，数据目录丢失"><a href="#十三-mysql无法启动，数据目录丢失" class="headerlink" title="十三.mysql无法启动，数据目录丢失"></a>十三.mysql无法启动，数据目录丢失</h3><p>问题描述： mysql无法启动，查看error日志，提示mysql.user不存在，查看my.cnf数据所在目录，发现目录里面除了ibdata1和ib_logfile，auto.cnf，没有其他数据。<br>分析：挂载mysql数据库目录丢失。mount的盘信息没写入fstab里面，断电重启后，没有挂载磁盘。<br>问题解决：<br>1.挂载数据库目录<br>mount -t ext3 /dev/sda3 /mysqldata<br>2.启动mysql<br>service mysql start</p>
<h3 id="十四-无法登陆mysql，can’t-connect。。。。mysql-sock"><a href="#十四-无法登陆mysql，can’t-connect。。。。mysql-sock" class="headerlink" title="十四.无法登陆mysql，can’t connect。。。。mysql.sock"></a>十四.无法登陆mysql，can’t connect。。。。mysql.sock</h3><p>问题描述：can’t connect 。。。。。。’/mysqldata/mysql/mysql.sock’<br>分析：在数据目录找不到mysql.sock文件或者mysql没有启动<br>问题解决：<br>1.找不到mysql.sock文件<br>登录加上-S 参数 或者ln -s 建立软连或者在my.cnf里面写上<br>mysql -uroot -p -S /usr/mysql.sock<br>或者 ln -s /usr/mysql.sock /mysqldata/mysql/mysql.sock<br>2.mysql没有启动<br>mysql.server start</p>
<h3 id="十五-数据目录存在非法目录"><a href="#十五-数据目录存在非法目录" class="headerlink" title="十五.数据目录存在非法目录"></a>十五.数据目录存在非法目录</h3><p>问题描述：错误日志显示mysql error invalid (old ) table or database name ‘lost+found’<br>分析：datadir里面的一个目录代表一个数据库，非法写入目录，导致mysql不能识别<br>问题解决：<br>删除目录’lost+found’。</p>
<h3 id="十六-错误日志报警告信息长度不匹配"><a href="#十六-错误日志报警告信息长度不匹配" class="headerlink" title="十六.错误日志报警告信息长度不匹配"></a>十六.错误日志报警告信息长度不匹配</h3><p>问题描述：[Warning] InnoDB: Table mysql/innodb_table_stats has length mismatch in the column name table_name. Please run mysql_upgrade<br>分析：5.7.17：table_name varchar(64) COLLATE utf8_bin NOT NULL,<br>5.7.24：table_name varchar(199) COLLATE utf8_bin NOT NULL,<br>可以看出，5.7.24 版本上的 innodb_index_stats 和innodb_tables_stats 的 table_name 列，长度从64 变成了 199，而升级后的5.7.24中 table_name 还是64</p>
<p>问题解决：<br>1.执行更新<br>mysql_upgrade -u root -p –force<br>2.重启mysqld进程<br>mysql.server start</p>
<h3 id="十七-错误日志报警告信息ignored-in-–skip-name-resolve-mode"><a href="#十七-错误日志报警告信息ignored-in-–skip-name-resolve-mode" class="headerlink" title="十七.错误日志报警告信息ignored in –skip-name-resolve mode"></a>十七.错误日志报警告信息ignored in –skip-name-resolve mode</h3><p>问题描述：[Warning] ‘user’ entry ‘mysql.session@localhost’ ignored in –skip-name-resolve mode.<br>分析：跳过dns解析，打开了skip_name_resolve后出现<br>问题解决：<br>删除不必要的账号<br>delete from mysql.user where user=‘mysql.session’</p>
<h3 id="十八-大量Waiting-in-connection-control-plugin连接"><a href="#十八-大量Waiting-in-connection-control-plugin连接" class="headerlink" title="十八.大量Waiting in connection_control plugin连接"></a>十八.大量Waiting in connection_control plugin连接</h3><p>问题描述:show processlist;结果超过2000条结果. 90%连接:Waiting in connection_control plugin<br>分析：启动了防爆破插件connection_control<br>问题解决:<br>show plugins;<br>select * from information_schema.CONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTS;<br>1.修改参数show variables like ‘%connection_control%’;<br>set global connection_control_failed_connections_threshold=0;<br>set global connection_control_max_connection_delay=3000;</p>
<p>或者2.重启mysql服务<br>mysql.server restart</p>
<p>3.kill进程<br>select concat(‘kill ‘, id, ‘;’) from information_schema.processlist where command= ‘Waiting in connection_control plugin’;</p>
<h3 id="十九-备库同步复制通道channel值为空"><a href="#十九-备库同步复制通道channel值为空" class="headerlink" title="十九.备库同步复制通道channel值为空"></a>十九.备库同步复制通道channel值为空</h3><p>现象描述：多源复制，同步复制通道channel值为空<br>问题分析：需要重置复制通道<br>问题解决:<br>1.停止slave<br>stop slave;<br>2.清空同步复制关联<br>reset slave all;<br>3.重置同步复制关联<br>change master to master_host = ‘192.168.137.110’, master_port = 3310, master_user = ‘rpl_user’, master_password = ‘xxxxxxxxxx’, master_auto_position=1 for channel ‘rpl1’;<br>4.启动slave<br>start slave;</p>
<p>另外，多源同步复制通道的知识点，官网和互联网上都很少，以下是经过本人实践的：<br>1.多源复制，同步复制通道channel修改。<br>1）update update mysql.slave_master_info set channel_name=“新通道名”;<br>2）service mysqld restart<br>3）show slave status\G; #这时候会多一条通道channel，旧通道和新通道<br>4）stop slave for channel “旧通道名”;<br>5）reset slave all for channel “旧通道名”;</p>
<p>2.多源复制，同步复制通道channel多一条，删除<br>1）stop slave for channel “删除通道名”;<br>2）reset slave all for channel “删除通道名”;#若是通道名为空，值””.<br>3）show slave status\G;</p>
<h3 id="二十-mysql时区跟系统数据不一致"><a href="#二十-mysql时区跟系统数据不一致" class="headerlink" title="二十.mysql时区跟系统数据不一致"></a>二十.mysql时区跟系统数据不一致</h3><p>问题描述：mysql&gt; select now();<br>±——————–+<br>| now() |<br>±——————–+<br>| 2020-05-27 06:27:24 |<br>±——————–+<br>1 row in set (0.00 sec)<br>mysql&gt; show global variables like ‘%time_zone%’;<br>±—————–±——-+<br>| Variable_name | Value |<br>±—————–±——-+<br>| system_time_zone | UTC |<br>| time_zone | SYSTEM |<br>±—————–±——-+<br>2 rows in set (0.01 sec)<br>mysql@tb6usrdb2:~&gt; date<br>Wed May 27 09:27:34 CEST 2020<br>分析：系统是CEST时区，与mysql的时区不一致，差3个小时<br>问题解决：<br>1.修改mysql时区：<br>set time_zone=’+2:00’; #+2,不是+3</p>
<p>2.结果：<br>mysql&gt; show global variables like ‘%time_zone%’;<br>±—————–±——-+<br>| Variable_name | Value |<br>±—————–±——-+<br>| system_time_zone | UTC |<br>| time_zone | +02:00 |<br>±—————–±——-+<br>2 rows in set (0.00 sec)</p>
<p>若是要永久生效就是在my.cnf中修改，添加default-time_zone=’+2:00’<br>然后重启mysql。<br>mysql&gt; show global variables like ‘%time_zone%’;<br>±—————–±——-+<br>| Variable_name | Value |<br>±—————–±——-+<br>| system_time_zone | CEST |<br>| time_zone | +02:00 |<br>±—————–±——-+<br>2 rows in set (0.00 sec)</p>
 
      <!-- reward -->
      
      <div id="reword-out">
        <div id="reward-btn">
          打赏
        </div>
      </div>
      
    </div>
    

    <!-- copyright -->
    
    <div class="declare">
      <ul class="post-copyright">
        <li>
          <i class="ri-copyright-line"></i>
          <strong>版权声明： </strong>
          
          本博客所有文章除特别声明外，著作权归作者所有。转载请注明出处！
          
        </li>
      </ul>
    </div>
    
    <footer class="article-footer">
       
<div class="share-btn">
      <span class="share-sns share-outer">
        <i class="ri-share-forward-line"></i>
        分享
      </span>
      <div class="share-wrap">
        <i class="arrow"></i>
        <div class="share-icons">
          
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="ri-weibo-fill"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="ri-wechat-fill"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="ri-qq-fill"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="ri-douban-line"></i>
          </a>
          <!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a> -->
          
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="ri-facebook-circle-fill"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="ri-twitter-fill"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="ri-google-fill"></i>
          </a>
        </div>
      </div>
</div>

<div class="wx-share-modal">
    <a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=http://example.com/2020/11/11/mysql/%E5%88%86%E4%BA%AB%E4%BA%8C%E5%8D%81%E4%B8%AAmysql%E8%BF%90%E7%BB%B4%E6%A1%88%E4%BE%8B/" alt="微信分享二维码">
    </div>
</div>

<div id="share-mask"></div>  
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/mysql/" rel="tag">mysql</a></li></ul>

    </footer>
  </div>

   
  <nav class="article-nav">
    
      <a href="/2020/11/11/mysql/MySQL%E7%B4%A2%E5%BC%95%E8%AF%A6%E8%A7%A3/" class="article-nav-link">
        <strong class="article-nav-caption">上一篇</strong>
        <div class="article-nav-title">
          
            MySQL索引详解.md
          
        </div>
      </a>
    
    
      <a href="/2020/11/11/other/%E5%8E%9F%E6%9D%A5%208%20%E5%BC%A0%E5%9B%BE%EF%BC%8C%E5%B0%B1%E5%8F%AF%E4%BB%A5%E6%90%9E%E6%87%82%E3%80%8C%E9%9B%B6%E6%8B%B7%E8%B4%9D%E3%80%8D%E4%BA%86/" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">原来 8 张图，就可以搞懂「零拷贝」了.md</div>
      </a>
    
  </nav>

   
<!-- valine评论 -->
<div id="vcomments-box">
  <div id="vcomments"></div>
</div>
<script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/valine@1.4.14/dist/Valine.min.js"></script>
<script>
  new Valine({
    el: "#vcomments",
    app_id: "",
    app_key: "",
    path: window.location.pathname,
    avatar: "monsterid",
    placeholder: "给我的文章加点评论吧~",
    recordIP: true,
  });
  const infoEle = document.querySelector("#vcomments .info");
  if (infoEle && infoEle.childNodes && infoEle.childNodes.length > 0) {
    infoEle.childNodes.forEach(function (item) {
      item.parentNode.removeChild(item);
    });
  }
</script>
<style>
  #vcomments-box {
    padding: 5px 30px;
  }

  @media screen and (max-width: 800px) {
    #vcomments-box {
      padding: 5px 0px;
    }
  }

  #vcomments-box #vcomments {
    background-color: #fff;
  }

  .v .vlist .vcard .vh {
    padding-right: 20px;
  }

  .v .vlist .vcard {
    padding-left: 10px;
  }
</style>

 
     
</article>

</section>
      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2015-2020
        <i class="ri-heart-fill heart_icon"></i> TzWind
      </li>
    </ul>
    <ul>
      <li>
        
        
        
        由 <a href="https://hexo.io" target="_blank">Hexo</a> 强力驱动
        <span class="division">|</span>
        主题 - <a href="https://github.com/Shen-Yu/hexo-theme-ayer" target="_blank">Ayer</a>
        
      </li>
    </ul>
    <ul>
      <li>
        
        
        <span>
  <span><i class="ri-user-3-fill"></i>访问人数:<span id="busuanzi_value_site_uv"></span></s>
  <span class="division">|</span>
  <span><i class="ri-eye-fill"></i>浏览次数:<span id="busuanzi_value_page_pv"></span></span>
</span>
        
      </li>
    </ul>
    <ul>
      
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
        <script type="text/javascript" src='https://s9.cnzz.com/z_stat.php?id=1278069914&amp;web_id=1278069914'></script>
        
      </li>
    </ul>
  </div>
</footer>
      <div class="float_btns">
        <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

<div class="todark" id="todark">
  <i class="ri-moon-line"></i>
</div>

      </div>
    </main>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/"><img src="/images/ayer-side.svg" alt="Hexo"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" target="_blank" rel="noopener" href="http://www.baidu.com">百度</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/friends">友链</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/2019/about">关于我</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="搜索">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <script>
      if (window.matchMedia("(max-width: 768px)").matches) {
        document.querySelector('.content').classList.remove('on');
        document.querySelector('.sidebar').classList.remove('on');
      }
    </script>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    
  </div>
</div>
    
<script src="/js/jquery-2.0.3.min.js"></script>


<script src="/js/lazyload.min.js"></script>

<!-- Tocbot -->


<script src="/js/tocbot.min.js"></script>

<script>
  tocbot.init({
    tocSelector: '.tocbot',
    contentSelector: '.article-entry',
    headingSelector: 'h1, h2, h3, h4, h5, h6',
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer: 'main',
    positionFixedSelector: '.tocbot',
    positionFixedClass: 'is-position-fixed',
    fixedSidebarOffset: 'auto'
  });
</script>

<script src="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.css">
<script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js"></script>

<script src="/dist/main.js"></script>

<!-- ImageViewer -->

<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.min.css">
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script>

<!-- MathJax -->

<!-- Katex -->

<!-- busuanzi  -->


<script src="/js/busuanzi-2.3.pure.min.js"></script>


<!-- ClickLove -->

<!-- ClickBoom1 -->

<!-- ClickBoom2 -->

<!-- CodeCopy -->


<link rel="stylesheet" href="/css/clipboard.css">

<script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>
<script>
  function wait(callback, seconds) {
    var timelag = null;
    timelag = window.setTimeout(callback, seconds);
  }
  !function (e, t, a) {
    var initCopyCode = function(){
      var copyHtml = '';
      copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
      copyHtml += '<i class="ri-file-copy-2-line"></i><span>COPY</span>';
      copyHtml += '</button>';
      $(".highlight .code pre").before(copyHtml);
      $(".article pre code").before(copyHtml);
      var clipboard = new ClipboardJS('.btn-copy', {
        target: function(trigger) {
          return trigger.nextElementSibling;
        }
      });
      clipboard.on('success', function(e) {
        let $btn = $(e.trigger);
        $btn.addClass('copied');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-checkbox-circle-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPIED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-checkbox-circle-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
      clipboard.on('error', function(e) {
        e.clearSelection();
        let $btn = $(e.trigger);
        $btn.addClass('copy-failed');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-time-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPY FAILED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-time-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
    }
    initCopyCode();
  }(window, document);
</script>


<!-- CanvasBackground -->


    
  </div>
</body>

</html>